package 双指针.盛最多水的容器11;

import utils.Utils;

public class Solution {
    public static int maxArea(int[] height) {
        int res = 0;
        for(int i=0,j=height.length-1;i<j;){
            int area = Math.min(height[i],height[j])*(j-i);
            res = Math.max(area,res);
            if(height[i]<= height[j]){
                i++;
            }else{
                j--;
            }
        }

        return res;
    }

    public static void main(String[] args) {
        int[] num = {1,8,6,2,5,4,8,3,7};
        Utils.printInt(maxArea(num));
    }
}
